﻿
using System.Linq;
using System.Windows.Controls;
using System.Windows.Media;
using wpf.Nursing.ViewModels;
using ZdfFlatUI.Utils;

namespace wpf.Nursing.Views
{
    /// <summary>
    /// BatchVitalSign.xaml 的交互逻辑
    /// </summary>
    public partial class BatchVitalSignView : UserControl
    {
        BatchVitalSignViewModel VMmodel;
        public BatchVitalSignView(BatchVitalSignViewModel model)
        {
            InitializeComponent();
            VMmodel = model;
            this.DataContext = VMmodel;
        }

        /// <summary>
        /// 重写自定义UI渲染函数  2023-05-23
        /// </summary>
        /// <param name="drawingContext"></param>
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);
            #region 查找DataGrid
            if (NursingRecordtMainGrid != null)
            {
                var regTxtList = My2VisualTreeHelper.FindVisualChildren<DataGrid>(NursingRecordtMainGrid).ToList();
                if (regTxtList != null && regTxtList.Count() > 0)
                {
                    if (VMmodel.dataGrid == null)
                    {
                        VMmodel.dataGrid = regTxtList[0];
                        VMmodel.Init();
                    }
                }
            }
            #endregion
        }
    }
}
